package com.usian.article.controller;

import com.usian.api.article.AuthorControllerApi;
import com.usian.article.service.ApAuthorService;
import com.usian.model.article.pojos.ApArticle;
import com.usian.model.article.pojos.ApAuthor;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.Path;

@RestController
@RequestMapping("/api/v1/author")
public class ApAuthorController implements AuthorControllerApi {

    @Autowired
    private ApAuthorService apAuthorService;

    @Override
    @PostMapping("save")
    public ResponseResult saveApAuthor(@RequestBody ApAuthor apAuthor) {
        return apAuthorService.saveApAuthor(apAuthor);
    }

    @Override
    @GetMapping("/findByUserId/{id}")
    public ApAuthor findByUserId(@PathVariable Integer id) {
        return apAuthorService.findByUserId(id);
    }

    @Override
    @GetMapping("findByName/{name}")
    public ApAuthor findByName(@PathVariable String name) {
        return apAuthorService.findByName(name);
    }

    @Override
    @GetMapping("/findByWmUserId/{id}")
    public ApAuthor findByWmUserId(@PathVariable("id") Integer id) {
        return apAuthorService.findByWmUserId(id);
    }

}
